namespace Brjnk.GpxExplorer.WPF
{
    using System;
    using System.Windows.Data;
    using Brjnk.Common;
    using Brjnk.GpxExplorer.ViewModel;

    /// <summary>
    /// </summary>
    public class TrackPointElevationConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is TrackPointAttributeValue<Distance>)
            {
                var distance = (TrackPointAttributeValue<Distance>)value;
                if (!distance.HasValue) return distance.ToString();
                return distance.Value.ToString(UnitsSettings.Instance.Elevation);
            }
            else return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}